/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = fix_fast.h                                                    */
/*  NOTE      =                                                               */
/*  DATE      = 2016/01/26 by zhengxd                                         */
/******************************************************************************/
#ifndef _FIX_FAST_H_
#define _FIX_FAST_H_

#define FIX_FAST_NONE_OPERATOR            0  //（无操作符）
#define FIX_FAST_CONSTANT_OPERATOR        1  //（常量操作符）
#define FIX_FAST_DEFAULT_OPERATOR         2  //（默认操作符）
#define FIX_FAST_COPY_OPERATOR            3  //（拷贝操作符）
#define FIX_FAST_INCREMENT_OPERATOR       4  //（增量操作符）
#define FIX_FAST_DELTA_OPERATOR           5  //（差量操作符
#define FIX_FAST_TAIL_OPERATOR            6  //（接尾操作符）

#define FIX_FAST_DATA_TP_INT32            0
#define FIX_FAST_DATA_TP_UINT32           1
#define FIX_FAST_DATA_TP_INT64            2
#define FIX_FAST_DATA_TP_UINT64           3
#define FIX_FAST_DATA_TP_DECIMAL          4
#define FIX_FAST_DATA_TP_STRING           5
#define FIX_FAST_DATA_TP_BYTE             6
#define FIX_FAST_DATA_TP_SEQUENCE         7
#define FIX_FAST_DATA_TP_GROUP            8

#define FIX_FAST_OPIONAL                  0
#define FIX_FAST_MANDATORY                1

#define FIX_FAST_STOP_BIT                 0x80

typedef struct __st_fix_fast_dec {

    int32_t i_exponential;      /* 指数 */
    int32_t i_mantissa;         /* 尾数 */
} Fix_fast_dec;

typedef struct __st_fix_fast_mod {

    int i_operator;             /* 操作符 */
    int i_data_type;            /* 数据类型 */
    int i_id;                   /* 字段ID */
    int i_presence;             /* 存在类型 */
    int i_decimal_idx;          /* 小数位数 */
    int i_pmap;                 /* PAMAP占位 */
    char *p_name;               /* 字段名 */
    int i_def_define;           /* 默认值是否定义过 */
    void *p_def_value;          /* 默认值 */
    unsigned int ui_def_size;  /* 默认值size */
    int i_pre_define;           /* 前值是否定义过 */
    void *p_pre_value;          /* 前值 */
    unsigned int ui_pre_size;  /* 前值size */
    int i_sub_node_flg;         /* 是否有子节点 */
    Frlist_header st_sub_node;  /* 子节点 */

}Fix_fast_mod;

void fix_fast_mod_node_free(Frlist_node *p_st_node);

void fix_fast_mod_reset(Frlist_header *p_lst_hd);


int fix_fast_init_szse_ua001(Frlist_header *p_lst_hd);

int fix_fast_init_szse_ua002(Frlist_header *p_lst_hd);

int fix_fast_init_szse_ua003(Frlist_header *p_lst_hd);

int fix_fast_init_szse_ua004(Frlist_header *p_lst_hd);

int fix_fast_init_szse_j(Frlist_header *p_lst_hd);

int fix_fast_init_szse_f(Frlist_header *p_lst_hd);

int fix_fast_init_szse_B(Frlist_header *p_lst_hd);

int fix_fast_init_szse_W(Frlist_header *p_lst_hd);

int fix_fast_init_szse_ua201(Frlist_header *p_lst_hd);

int fix_fast_init_szse_ua202(Frlist_header *p_lst_hd);

int fix_fast_init_sse_3201(Frlist_header *p_lst_hd);

int fix_fast_init_sse_3202(Frlist_header *p_lst_hd);

int fix_fast_init_sse_3107(Frlist_header *p_lst_hd);

int fix_fast_init_sse_3113(Frlist_header *p_lst_hd);

int fix_fast_init_sse_3115(Frlist_header *p_lst_hd);

int fix_fast_decode_int32(char **pp_inbuff
                          , unsigned int *p_ui_size
                          , int i_presence
                          , void **pp_value
                          , unsigned int *p_ui_out);

int fix_fast_decode_uint32(char **pp_inbuff
                          , unsigned int *p_ui_size
                          , int i_presence
                          , void **pp_value
                          , unsigned int *p_ui_out);

int fix_fast_decode_int64(char **pp_inbuff
                          , unsigned int *p_ui_size
                          , int i_presence
                          , void **pp_value
                          , unsigned int *p_ui_out);

int fix_fast_decode_uint64(char **pp_inbuff
                          , unsigned int *p_ui_size
                          , int i_presence
                          , void **pp_value
                          , unsigned int *p_ui_out);

int fix_fast_decode_decimal(char **pp_inbuff
                            , unsigned int *p_ui_size
                            , int i_presence
                            , void **pp_value
                            , unsigned int *p_ui_out);

int fix_fast_decode_ascii(char **pp_inbuff
                          , unsigned int *p_ui_size
                          , int i_presence
                          , void **pp_value
                          , unsigned int *p_ui_out);

int fix_fast_decode_unicode(char **pp_inbuff
                            , unsigned int *p_ui_size
                            , int i_presence
                            , void **pp_value
                            , unsigned int *p_ui_out);

int fix_fast_parse_raw(char **pp_inbuff
                       , unsigned int *p_ui_size
                       , Frlist_header *p_lst_mod
                       , Frlist_header *p_lst_hd
                       , unsigned int *p_ui_deeps
                       , unsigned int ui_deep
                       , char *p_pamp
                       , unsigned int ui_pmap_size
                       , unsigned int *p_ui_loop
                       , unsigned int *p_ui_loop_loop);

int fix_fast_get_pamp(char **pp_inbuff
                      , unsigned int *p_ui_size
                      , unsigned int *p_ui_pmap_size);

#endif
